﻿using System.Collections.Generic;

namespace WorkFlow.Data.Model
{
    public class NodeState
    {
        public bool @checked,
          disabled,
          expanded,
          selected;
    }
    public class RuleDetailEntity
    {
        public RuleDetailEntity()
        {


        }
        public RuleDetailEntity(int id, int type, string name, string value)
        {
            _ID = id;
            _Type = type;
            _Name = name;
            _Value = value;
        }
        int _ID;
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        int _ParentID;
        public int ParentID
        {
            get { return _ParentID; }
            set { _ParentID = value; }
        }
        int _Type;
        public int Type
        {
            get { return _Type; }
            set { _Type = value; }
        }
        string _Name;
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        string _Value;
        public string Value
        {
            get { return _Value; }
            set { _Value = value; }
        }
        int _ValueType;
        public int ValueType
        {
            get { return _ValueType; }
            set { _ValueType = value; }
        }
        public string Text
        {
            get
            {
                switch (_Type)
                {
                    case 1:
                        return "&";
                    case 2:
                        return "|";
                    case 3:
                        return "!";
                    case 4:
                        return _Name + "=" + _Value;
                    case 5:
                        return _Name + "!=" + _Value;
                    case 6:
                        return _Name + ">" + _Value;
                    case 7:
                        return _Name + ">=" + _Value;
                    case 8:
                        return _Name + "<" + _Value;
                    case 9:
                        return _Name + "<=" + _Value;
                    default:
                        return "null";
                }
            }
        }

        List<RuleDetailEntity> _nodes=new List<RuleDetailEntity>();
        public List<RuleDetailEntity> Nodes
        {
            get { return _nodes; }
            set { _nodes = value; }
        }

        bool _IsNew;
        public bool IsNew
        {
            get { return _IsNew; }
            set { _IsNew = value; }
        }

        Dictionary<string, bool> _State = InitState();
        public Dictionary<string, bool> state
        {
            get
            {
                return _State;
            }
            set { _State = value; }
        }
        public static Dictionary<string, bool> InitState()
        {
            Dictionary<string, bool> keyValuePairs = new Dictionary<string, bool>();
            keyValuePairs["checked"] = false;
            keyValuePairs["disabled"] = false;
            keyValuePairs["expanded"] = true;
            keyValuePairs["selected"] = false;
            return keyValuePairs;
        }

    }
}
